/**
 * create by Alec
 */
import { createAction } from "redux-actions";
import fetch from "../../utils/fetch.js";
import { get } from "../../utils/db";

export const getConfirm = createAction("CONFIRM_DATA");
export const getAllDropDown = createAction("OPTIONS");
export const fetchConfirm = userId => dispatch =>
  fetch(`/hrmregister/mobile/confirm/getConfirmInfo`, {
    body: { userId },
    meta: {
      dipId: 65396,
      silence: true
    }
  }).then(res => {
    if (res.success) {
      dispatch(getConfirm(res.result));
    }
    return res;
  });

export const fetchAllDropDown = () => dispatch =>
  fetch(`${get("baseUrl")}getAllDropDownMap`, {
    meta: {
      dipId: 65431
    }
  }).then(res => {
    if (res.success) {
      dispatch(getAllDropDown(res.result));
    }
    return res;
  });

export const confirmEntryInfo = param => () =>
  fetch(`/hrmregister/mobile/confirm/confirmEntryInfo`, {
    body: param,
    meta: {
      dipId: 65396
    }
  });

export const confirmSuccessInfo = userId => () =>
  fetch(`/hrmregister/mobile/confirm/getEmpDetailInfo`, {
    body: { userId },
    meta: {
      dipId: 65557
    }
  });
